package com.gcy.checkcertificate.config;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.StringUtils;

/**
 * <Description> <br>
 *
 * @author linmiaolai@sanyygp.com<br>
 * @version 1.0<br>
 * @date 2024/01/26 <br>
 */
public class GroupCondition  implements Condition {
    /**
     * 只有配置分组名称和分组路径才返回true
     */
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        String groupName = context.getEnvironment().getProperty("swagger.group.name");
        String groupPathRegex = context.getEnvironment().getProperty("swagger.group.pathRegex");
        return !StringUtils.isEmpty(groupName) && !StringUtils.isEmpty(groupPathRegex);
    }
}
